#include <myhead.h>
int main(int argc, const char *argv[])
{
	sqlite3* sql_db=NULL;
	//打开数据库
	if(sqlite3_open("001.db",&sql_db)!=0){printf("打开数据库失败\n");return -1;}

	//1、
	const char*sql="select password from user_data where name=?";
	char select_name[20]={0};
	sqlite3_stmt*stmt=NULL;
	while(1)
	{
		printf("请输入要查询的账户:");
		scanf("%s",select_name);
		while(getchar()!=10);
		sqlite3_prepare_v2(sql_db,sql,-1,&stmt,NULL);
		sqlite3_bind_text(stmt,1,select_name,strlen(select_name),NULL);
		int res=sqlite3_step(stmt);
		if(res==SQLITE_DONE)
			printf("无此数据\n");
		else if(res==SQLITE_ROW)
		{
			const char*password=sqlite3_column_text(stmt,0);
			printf("密码:%s\n",password);
		}
	}

	//关闭数据库
	sqlite3_close(sql_db);
	return 0;
}
